<template>
  <div style="padding:30px;width:150%">
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="115px"
      class="demo-ruleForm"
    >
      <el-form-item label="合同名称" prop="name">
        <el-col :span="22">
          <el-input v-model="ruleForm.name"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="预收款" prop="advReceived">
        <el-col :span="22">
          <el-input v-model="ruleForm.advReceived"></el-input>
        </el-col>
      </el-form-item>
      <el-form-item label="考核金额" prop="cheMoney">
        <el-col :span="22">
          <el-input v-model="ruleForm.cheMoney"></el-input>
        </el-col>
      </el-form-item>
      <!-- 这里应该有个总公司的id的，可能是默认带了 -->
      <el-form-item label="合同编号" prop="cheMoney">
        <el-col :span="22">
          <el-input v-model="ruleForm.cheMoney"></el-input>
        </el-col>
      </el-form-item>
      <el-form-item label="合同文本" prop="conText">
        <el-col :span="22">
          <el-input type="textarea" v-model="ruleForm.conText"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="执行时间" required>
        <el-form-item prop="executeTime">
          <el-col :span="22">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="ruleForm.executeTime"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
            ></el-date-picker>
          </el-col>
        </el-form-item>
      </el-form-item>

      <el-form-item label="完成时间" required>
        <el-form-item prop="finishTime	">
          <el-col :span="22">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="ruleForm.finishTime	"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
            ></el-date-picker>
          </el-col>
        </el-form-item>
      </el-form-item>

      <el-form-item label="是否执行" prop="flag">
        <el-col :span="22">
          <el-input v-model="ruleForm.flag"></el-input>
        </el-col>
      </el-form-item>
      <!-- 这里应该有个合同的主键的id的，可能是默认带了 -->
      <!-- 这里应该有个部门的的id的，可能是默认带了 -->
      <el-form-item label="联系人" prop="relPerson">
        <el-radio-group v-model="ruleForm.relPerson">
          <el-radio label="联系人1"></el-radio>
          <el-radio label="联系人2"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="签约人" prop="signPerson">
        <el-radio-group v-model="ruleForm.signPerson">
          <el-radio label="签约人1"></el-radio>
          <el-radio label="签约人2"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="签约时间" required>
        <el-form-item prop="signTime">
          <el-col :span="22">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="ruleForm.signTime"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
            ></el-date-picker>
          </el-col>
        </el-form-item>
      </el-form-item>

      <el-form-item label="电话" prop="telephone">
        <el-col :span="22">
          <el-input v-model="ruleForm.telephone"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="分公司" prop="uid">
        <el-radio-group v-model="ruleForm.uid">
          <el-radio label="分公司1"></el-radio>
          <el-radio label="分公司2"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { hqfgs, tjht } from "@/api/ht";
import { getToken, gettype } from "@/utils/auth";

export default {
  name: "DragTable",

  data() {
    return {
      list: null,
      ruleForm: {
        name: "",
        advReceived: "",
        cheMoney: ""
      },
      rules: {
        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        sex: [{ required: true, message: "请选择性别", trigger: "change" }],
        // self: [
        //   { required: true, message: '请选择与本人关系', trigger: 'change' }
        // ],
        type_name: [
          { required: true, message: "请输入与本人关系", trigger: "blur" }
        ],
        jhrname: [
          { required: false, message: "请输入监护人姓名", trigger: "blur" }
        ],
        // date: [
        //   {  required: true, message: '请选择日期', trigger: 'change' }
        // ],
        hkregion: [
          {
            type: "string",
            required: true,
            message: "请选择地区",
            trigger: "change"
          }
        ],
        hkxxregion: [
          { required: true, message: "请输入详细地址", trigger: "blur" }
        ],
        nowregion: [
          {
            type: "string",
            required: true,
            message: "请选择地区",
            trigger: "change"
          }
        ],
        nowxxregion: [
          { required: true, message: "请输入详细地址", trigger: "blur" }
        ],
        age: [
          { required: true, message: "请输入年龄", trigger: "blur" },
          { min: 1, max: 5, message: "长度在 1 到 5 个字符", trigger: "blur" }
        ],
        idcard: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
          { min: 18, max: 18, message: "请输入18位身份证号", trigger: "blur" }
        ],
        mobile: [
          { required: true, message: "请输入手机号", trigger: "blur" },
          { min: 11, max: 11, message: "请输入11手机号", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      tjht(this.ruleForm).then(response => {
        console.log(response.data);
        var data = response.data.object;
        console.log(data);
        setToken(data.token);
        setid(data.id);
        settype(data.usertype);
        console.log(22222);
        this.$router.push("/");
      });
    }
  }
};
</script>

<style>
.sortable-ghost {
  opacity: 0.8;
  color: #fff !important;
  background: #42b983 !important;
}
</style>

<style scoped>
.icon-star {
  margin-right: 2px;
}
.drag-handler {
  width: 20px;
  height: 20px;
  cursor: pointer;
}
.show-d {
  margin-top: 15px;
}
.el-alert__content {
  width: 50%;
}

</style>
